<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->


<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-cn" xml:lang="zh-cn">
<head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="DC.Type" content="topic">
<meta name="DC.Title" content="获取Token信息">
<meta name="product" content="">
<meta name="DC.Relation" scheme="URI" content="kubernetes_CSI_00017.html">
<meta name="prodname" content="">
<meta name="version" content="">
<meta name="brand" content="">
<meta name="DC.Publisher" content="20250306">
<meta name="prodname" content="csbs">
<meta name="documenttype" content="usermanual">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="kubernetes_CSI_00020">
<meta name="DC.Language" content="zh-cn">
<link rel="stylesheet" type="text/css" href="public_sys-resources/commonltr.css">
<title>获取Token信息</title>
</head>
<body style="clear:both; padding-left:10px; padding-top:5px; padding-right:5px; padding-bottom:5px"><a name="kubernetes_CSI_00020"></a><a name="kubernetes_CSI_00020"></a>

<h1 class="topictitle1">获取Token信息</h1>
<div><p>当后续需要通过Token认证的方式注册集群时，可参考本节操作获取超级管理员的Token。使用本节方法获取的Token可永久使用。</p>
<div class="section"><h4 class="sectiontitle">操作步骤</h4><ol><li><span>通过后台登录Kubernetes集群。</span></li><li><span>执行以下命令，使用指定名称创建服务用户。后续步骤以创建的用户名为test进行说明。</span><p><pre class="screen" id="kubernetes_CSI_00020__kubernetes_csi_00019_screen774314917566">oc create serviceaccount<em id="kubernetes_CSI_00020__kubernetes_csi_00019_i15731183210564"> </em><em id="kubernetes_CSI_00020__kubernetes_csi_00019_i526717330560">用户名</em></pre>
</p></li><li><span>执行以下命令，给“test”用户授予“cluster-admin”角色。</span><p><pre class="screen" id="kubernetes_CSI_00020__kubernetes_csi_00019_screen1445974610356">oc adm policy add-cluster-role-to-user cluster-admin -z <em id="kubernetes_CSI_00020__kubernetes_csi_00019_i166264116452">test</em></pre>
</p></li><li id="kubernetes_CSI_00020__li1375865225918"><a name="kubernetes_CSI_00020__li1375865225918"></a><a name="li1375865225918"></a><span>执行<strong>oc describe ServiceAccount</strong> <em>test</em>命令获取用户的secret名称，对应值为“Tokens”参数值。</span><p><p><span><img src="zh-cn_image_0000002164749986.png"></span></p>
</p></li><li><span>执行以下命令获取Token信息，“token”参数值即为超级管理员的Token（“test-token-7zrz9”为<a href="#kubernetes_CSI_00020__li1375865225918">4</a>获取的secret名称）。</span><p><pre class="screen">oc describe secret <em>test-token-7zrz9</em></pre>
</p></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>父主题：</strong> <a href="kubernetes_CSI_00017.html">备份前准备（适用于OpenShift）</a></div>
</div>
</div>

<div class="hrcopyright"><hr size="2"></div><div class="hwcopyright">版权所有 &copy; 华为技术有限公司</div></body>
</html>